package com.acme.bankapp.listeners.email;

public class EmailService implements Runnable {
	Queue q = new Queue();
	private Thread tr;
	private boolean flag = true;

	public void sendNotificationEmile(Email email) {
		q.add(email);

	}

	public EmailService() {
		tr = new Thread(this);
		tr.start();
	}

	@Override
	public void run() {
		Email e;
		while (flag) {
			e = q.get();
			if (e != null) {
				System.out.println(e);
			}
		}
	}

	public void close() {
		flag = false;
		q.close();
	}
}
